from DrissionPage import ChromiumPage
from time import sleep

page = ChromiumPage()
try:
    page.get('http://212.11.10.20/#/login')
    ###用户名默认已填写
    page.ele('@placeholder=密码').input('zxm,10***')
    # # 等待验证码图片加载（最多10秒）
    # captcha = page.ele("@class=verificationCodeTmg").wait(10)
    # # 手动输入验证码（或调用OCR识别）
    # user_input = input("请输入验证码：")
    # page.ele("@placeholder=验证码").input(user_input)
    #提交登录
    page.ele('@type=button').click()
except:
    pass
    sleep(4)  # 等待页面加载完成
try:
    page.ele('t:li@@title=门禁管理').wait(2).click()
except:
    pass
    iframe = page.ele('')
    # 获取iframe内部的document对象
    iframe_doc = iframe.inner_html
    # 或者直接通过iframe对象操作内部元素
    iframe_element = iframe.inner_ele
    internal_element = iframe_element.ele('@class=first-accordion ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-accordion-header-active ui-state-active ui-corner-top')
    internal_element.click()



page.quit()
